package cn.yj.syslog.aspect.pageview;

import cn.yj.syslog.service.IPageViewService;
import org.springframework.aop.support.StaticMethodMatcherPointcutAdvisor;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RestController;

import java.lang.reflect.Method;

/**
 * @author 永健
 * @since 2021-04-15 14:29
 */
@Component
public class PageViewStaticMethodMatcherPointcutAdvisor extends StaticMethodMatcherPointcutAdvisor {

    public PageViewStaticMethodMatcherPointcutAdvisor(IPageViewService pageViewService) {
        super.setAdvice(new PageViewLogMethodInterceptor(pageViewService));
    }

    @Override
    public boolean matches(Method method, Class<?> aClass) {
        return aClass.getAnnotation(RestController.class) != null || aClass.getAnnotation(Controller.class) != null;
    }
}
